package o;

import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.ProtocolException;
import java.net.UnknownServiceException;
import java.security.cert.CertificateException;
import java.util.Arrays;
import java.util.List;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLProtocolException;
import javax.net.ssl.SSLSocket;

public final class fvo {
    private boolean ˊ;
    private int ˎ = 0;
    private boolean ˏ;
    private final List<fud> ॱ;

    public fvo(List<fud> list) {
        this.ॱ = list;
    }

    public fud ˊ(SSLSocket sSLSocket) throws IOException {
        fud o_fud;
        int i = this.ˎ;
        int size = this.ॱ.size();
        for (int i2 = i; i2 < size; i2++) {
            o_fud = (fud) this.ॱ.get(i2);
            if (o_fud.ˊ(sSLSocket)) {
                this.ˎ = i2 + 1;
                break;
            }
        }
        o_fud = null;
        if (o_fud == null) {
            throw new UnknownServiceException("Unable to find acceptable protocols. isFallback=" + this.ˏ + ", modes=" + this.ॱ + ", supported protocols=" + Arrays.toString(sSLSocket.getEnabledProtocols()));
        }
        this.ˊ = ˎ(sSLSocket);
        fux.ˏ.ˋ(o_fud, sSLSocket, this.ˏ);
        return o_fud;
    }

    public boolean ˎ(IOException iOException) {
        this.ˏ = true;
        if (!this.ˊ || (iOException instanceof ProtocolException) || (iOException instanceof InterruptedIOException)) {
            return false;
        }
        if (((iOException instanceof SSLHandshakeException) && (iOException.getCause() instanceof CertificateException)) || (iOException instanceof SSLPeerUnverifiedException)) {
            return false;
        }
        if ((iOException instanceof SSLHandshakeException) || (iOException instanceof SSLProtocolException) || (iOException instanceof SSLException)) {
            return true;
        }
        return false;
    }

    private boolean ˎ(SSLSocket sSLSocket) {
        for (int i = this.ˎ; i < this.ॱ.size(); i++) {
            if (((fud) this.ॱ.get(i)).ˊ(sSLSocket)) {
                return true;
            }
        }
        return false;
    }
}
